package com.util;

import java.util.Random;

public class Random4 {
    static Random random = new Random();
    public static void main(String[] args) {
        System.out.println(random6());
    }

    public static int random6 () {

        while (true) {
//            这样随机生成了0~24的数字，对7%，就随机得到0~6。扩大随机范围再取余的思想，加法填充
            int random = Random4.random.nextInt(5) * 5 + Random4.random.nextInt(5);

            if (random <= 21) {
                return random % 7;
            }
        }
    }
}
